package com.huidatech.demo.config;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.context.annotation.Configuration;

import java.util.Date;

/**
 * ClassName: MyMetaObjectHandler
 * Function:
 * Date:      2021/10/7 10:52 下午
 * author     Wangzhuang2
 * version    V1.0
 * TODO:
 */
@Configuration
public class MyMetaObjectHandler implements MetaObjectHandler {
    /*
    * 此种版本的写法适用于： 【version - 3.3.0后面的版本】
    *
    * */
    @Override
    public void insertFill(MetaObject metaObject) {
        this.fillStrategy(metaObject, "createTime", new Date());
        this.fillStrategy(metaObject, "updateTime", new Date());
    }

    @Override
    public void updateFill(MetaObject metaObject) {
        this.fillStrategy(metaObject, "updateTime", new Date());
    }
}

